<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="160px">
      <el-form-item label="企业账号:">
        {{ form.business_name || '--' }}
        <i v-if="form.business_status == 1" class="el-icon-search">未审核</i>
        <i v-if="form.business_status == 2" class="el-icon-success">已审核</i>
      </el-form-item>
      <div class="title">商家基本信息</div>
      <el-form-item label="商家名称:">
        {{ form.business_name || '--' }}
      </el-form-item>
      <el-form-item label="纳税人识别号:">
        {{ form.company_identify_number || '--' }}
      </el-form-item>
      <el-form-item label="法人姓名:">
        {{ form.legal_person_name || '--' }}
      </el-form-item>
      <el-form-item label="法人联系方式:">
        {{ form.legal_person_contact || '--' }}
      </el-form-item>
      <el-form-item label="法人身份证号:">
        {{ form.legal_person_identity_number || '--' }}
      </el-form-item>
      <el-form-item label="商家营业执照:">
        <div class="showImg">
           <img :src="form.business_license" @click="clickImg($event)" alt="商家营业执照">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <el-form-item label="法人身份证人像面:">
        <div class="showImg">
           <img :src="form.legal_person_identity_card[0]" @click="clickImg($event)" alt="法人身份证人像面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <el-form-item label="法人身份国徽面:">
        <div class="showImg">
           <img :src="form.legal_person_identity_card[1]" @click="clickImg($event)" alt="法人身份国徽面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <div class="title">商家服务信息</div>
      <el-form-item label="主营类目:">
        {{ form.enterprise_main_project.join() || '--' }}
      </el-form-item>
      <el-form-item label="店铺地址:">
        {{ form.shop_address || '--' }}
      </el-form-item>
      <el-form-item label="门脸照:">
        <div class="showImg">
           <img :src="form.door_curtain" @click="clickImg($event)" alt="门脸照">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <div class="title">商家财务信息</div>
      <el-form-item label="商家对公账号:">
        <span v-text="form.busPublic"></span>
      </el-form-item>
      <el-form-item label="开户行及支行:">
        {{ form.enterprise_opening_bank || '--' }}
      </el-form-item>
      <el-form-item label="财务联系人姓名:">
        {{ form.financial_contact_name || '--' }}
      </el-form-item>
      <el-form-item label="财务联系人电话:">
        {{ form.financial_contact_phone || '--' }}
      </el-form-item>
      <el-form-item label="财务联系人身份证号:">
        {{ form.financial_identity_number || '--' }}
      </el-form-item>
      <el-form-item label="财务身份证人像面:">
        <div class="showImg">
           <img :src="form.financial_identity_card[0]" @click="clickImg($event)" alt="财务身份证人像面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <el-form-item label="财务身份国徽面:">
        <div class="showImg">
           <img :src="form.financial_identity_card[1]" @click="clickImg($event)" alt="财务身份国徽面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <div class="title">商家管理人信息</div>
      <el-form-item label="商户联系人姓名:">
        {{ form.business_contacts_name || '--' }}
      </el-form-item>
      <el-form-item label="商户联系人电话:">
        {{ form.business_mobile_phone || '--' }}
      </el-form-item>
      <el-form-item label="管理人身份证号:">
        {{ form.enterprise_contact_identity_number || '--' }}
      </el-form-item>
      <el-form-item label="管理人身份证人像面:">
        <div class="showImg">
           <img :src="form.enterprise_contact_identity_card[0]" @click="clickImg($event)" alt="管理人身份证人像面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <el-form-item label="管理人身份国徽面:">
        <div class="showImg">
           <img :src="form.enterprise_contact_identity_card[1]" @click="clickImg($event)" alt="管理人身份国徽面">
           <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        </div>
      </el-form-item>
      <el-form-item>
        <el-button v-if="form.business_status == 1" @click="pass(2)" type="primary">通过</el-button>
        <el-button v-if="form.business_status == 1" @click="dialogVisible = true" >不通过</el-button>
        <el-button v-if="form.business_status == 2" type="danger">冻结</el-button>
        <el-button type="info" @click="back">返回</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="审核不通过提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <div>
        该商家信息审核完毕，确认无法通过审核？
        <p class="red">未通过原因：</p>
        <el-input
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 4}"
          placeholder="请输入内容"
          v-model="textarea">
        </el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false;pass(3)">确 定</el-button>
      </span>
    </el-dialog>
  </div>

</template>

<script>
import { validateOrderStatus } from '@/utils/validate'
import { formatDate } from '@/utils/index'
import request from '@/utils/request'
import BigImg from '@/views/collage/showImg.vue';
export function getList(mes,url) {
  return request({
    url: url,
    method: 'post',
    data: mes
  })
}
export default {
  data() {
    return {
      form: {},
      dialogVisible: false,
      textarea: '',
      showImg:false,
      imgSrc: ''
    }
  },
  created: function () {
    this.form = JSON.parse(localStorage.getItem('busMes'))
    console.log(this.form);
  },
  components: {
    'big-img':BigImg
  },
  methods: {
    pass(n) {
      const m = {
        _id: this.form._id,
        business_status: n,
        business_status_text: this.textarea
      }
      console.log(m);
      getList(m,'/v1/admin/business/update').then(res => {
          if (res.code === 200) {
            this.$message({
              message: '操作成功！',
              type: 'success'
            });
            this.$router.go(-1)
          } else {
            this.$message({
              message: res.msg,
              type: 'error'
            });
          }
        }).catch(error => {
          this.$message({
            message: error,
            type: 'error'
          });
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    back() {
      this.$router.go(-1)
    },
    clickImg(e) {
        this.showImg = true;
        // 获取当前图片地址
        this.imgSrc = e.currentTarget.src;
    },
    viewImg(){
        this.showImg = false;
    },
  }
}
</script>
<style scoped>
  .title{
    height: 30px;
    line-height: 30px;
    font-weight: bold;
    border-top: 1px solid #d4d4d4;
  }
  .red{
    color: red;
  }
  .el-icon-success{
    color: green;
    margin-left: 20px;
  }
  .el-icon-search{
    color: #5a5a5a;
    margin-left: 20px;
  }
  .el-form-item__content img{
    max-width: 300px;
    max-height: 300px;
    box-shadow: 0 0 10px #cccccc;
    border-radius: 5px;
  }
</style>
